<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <div id="app">
        <h3>这是父亲</h3>
        <p>{{letter}}</p>
        <hr>
        <son @sendtofather="accept"></son>
    </div>

    <template id="son">
        <div>
            <h3>这是儿子</h3>
            <input type="text" v-model="message" @input="send">
        </div>
    </template>

    <script src="../lib/Vue/vue.js"></script>
    <script>

        var vm = new Vue({
            el: '#app',
            data: {
                letter: ''
            },
            methods: {
                accept(data) {
                    this.letter = data
                }
            },
            components: {
                son: {
                    template: '#son',
                    data() {
                        return {
                            message: ''
                        }
                    },
                    methods: {
                        send() {
                            this.$emit('sendtofather', this.message)
                        }
                    },
                }
            }
        })
    </script>
</body>
</html>